package com.linkwechat.common.utils;

import java.util.Random;
import java.util.UUID;

/**
 * @Author 王君平
 * @Date 2023/8/28 14:19
 * @Description
 */
public class RandomUtil {

    public static final String uuid(){
        return UUID.randomUUID().toString().replace("-","");
    }

    /**
     * @param length  用户要求产生字符串的长度
     * @return
     */
    public static String getRandomString(int length){
        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random=new Random();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<length;i++){
            int number=random.nextInt(62);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }
}
